Initialize default parameters and simulator¶
In [2]:
from rdtattoo import tattoo_plotter as tp
import plotly
from rdtattoo.plotly_colorscales import oslo
from rdtattoo.rd_defaults import grayscott_worm_default
plotly.offline.init_notebook_mode()
sim = grayscott_worm_default
Generate random initial arrays and run the model¶
In [2]:
a_initial,
Plot the resulting simulation¶
In [ ]:
fig = tp.create_plotly_figure(a2, oslo, 1)
fig.show()
Varying the textures¶
We can manipulate the textures by changing A/B
In [ ]:
rd.alpha = 0.01
rd.beta = 0.25
t, output_a, output_b = rd.run(a, b)
tp.create_plotly_figure(output_a, oslo, 1)
In [ ]:
rd.alpha = 0.01
rd.beta = 1
t, output_a, output_b = rd.run(a, b)
tp.create_plotly_figure(output_a, oslo, 1)
In [ ]:
import numpy as np
from scipy.ndimage.interpolation import rotate
def average_rotate(a, degree):
"""
Takes a 2d array a, and produces the average arrays,
having rotated it degree times. The resulting shape
has approximate degree-fold rotational symmetry.
"""
theta = 360 / degree
a = np.mean([rotate(a, theta * i, reshape=False) for i in range(degree)], axis=0)
return a
def random_symmetric_initialiser(shape, degree):
"""
Random initialiser with degree-fold symmetry.
"""
a = np.random.normal(loc=0, scale=0.05, size=shape)
b = np.random.normal(loc=0, scale=0.05, size=shape)
return (
average_rotate(a, degree),
average_rotate(b, degree)
)
In [8]:
rx = random_symmetric_initialiser((100,100), 5)
In [ ]:
import matplotlib.pyplot as plt
plt.imshow(rx[0])
In [4]:
import rd_simulator_gui as rds
rds.create_max_value_sim(rds.fitzhugh_nagumo_default, 10).model_dump()
Out[4]:
{'Da': 10.0,
'Db': 1000.0,
'alpha': -0.05,
'beta': 100.0,
'dx': 10.0,
'dt': 0.01,
'width': 2000,
'height': 2000,
'steps': 200000,
'frames': 1000,
'reaction_type': <ReactionType.FITZHUGH_NAGUMO: 2>}
In [13]:
import numpy as np
import matplotlib.pyplot as plt
plt.scatter(np.linspace(0, 1, 21), np.logspace(0.1, 10, 21), log=True)
%matplotlib inline
plt.show()
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[13], line 3 1 import numpy as np 2 import matplotlib.pyplot as plt ----> 3 plt.scatter(np.linspace(0, 1, 21), np.logspace(0.1, 10, 21), log=True) 4 get_ipython().run_line_magic('matplotlib', 'inline') 8 plt.show() File ~/Documents/developer/RDtattoo/.venv/lib/python3.13/site-packages/matplotlib/_api/deprecation.py:453, in make_keyword_only.<locals>.wrapper(*args, **kwargs) 447 if len(args) > name_idx: 448 warn_deprecated( 449 since, message="Passing the %(name)s %(obj_type)s " 450 "positionally is deprecated since Matplotlib %(since)s; the " 451 "parameter will become keyword-only in %(removal)s.", 452 name=name, obj_type=f"parameter of {func.__name__}()") --> 453 return func(*args, **kwargs) File ~/Documents/developer/RDtattoo/.venv/lib/python3.13/site-packages/matplotlib/pyplot.py:3937, in scatter(x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, edgecolors, colorizer, plotnonfinite, data, **kwargs) 3917 @_copy_docstring_and_deprecators(Axes.scatter) 3918 def scatter( 3919 x: float | ArrayLike, (...) 3935 **kwargs, 3936 ) -> PathCollection: -> 3937 __ret = gca().scatter( 3938 x, 3939 y, 3940 s=s, 3941 c=c, 3942 marker=marker, 3943 cmap=cmap, 3944 norm=norm, 3945 vmin=vmin, 3946 vmax=vmax, 3947 alpha=alpha, 3948 linewidths=linewidths, 3949 edgecolors=edgecolors, 3950 colorizer=colorizer, 3951 plotnonfinite=plotnonfinite, 3952 **({"data": data} if data is not None else {}), 3953 **kwargs, 3954 ) 3955 sci(__ret) 3956 return __ret File ~/Documents/developer/RDtattoo/.venv/lib/python3.13/site-packages/matplotlib/_api/deprecation.py:453, in make_keyword_only.<locals>.wrapper(*args, **kwargs) 447 if len(args) > name_idx: 448 warn_deprecated( 449 since, message="Passing the %(name)s %(obj_type)s " 450 "positionally is deprecated since Matplotlib %(since)s; the " 451 "parameter will become keyword-only in %(removal)s.", 452 name=name, obj_type=f"parameter of {func.__name__}()") --> 453 return func(*args, **kwargs) File ~/Documents/developer/RDtattoo/.venv/lib/python3.13/site-packages/matplotlib/__init__.py:1521, in _preprocess_data.<locals>.inner(ax, data, *args, **kwargs) 1518 @functools.wraps(func) 1519 def inner(ax, *args, data=None, **kwargs): 1520 if data is None: -> 1521 return func( 1522 ax, 1523 *map(cbook.sanitize_sequence, args), 1524 **{k: cbook.sanitize_sequence(v) for k, v in kwargs.items()}) 1526 bound = new_sig.bind(ax, *args, **kwargs) 1527 auto_label = (bound.arguments.get(label_namer) 1528 or bound.kwargs.get(label_namer)) File ~/Documents/developer/RDtattoo/.venv/lib/python3.13/site-packages/matplotlib/axes/_axes.py:5049, in Axes.scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, edgecolors, colorizer, plotnonfinite, **kwargs) 5045 keys_str = ", ".join(f"'{k}'" for k in extra_keys) 5046 _api.warn_external( 5047 "No data for colormapping provided via 'c'. " 5048 f"Parameters {keys_str} will be ignored") -> 5049 collection._internal_update(kwargs) 5051 # Classic mode only: 5052 # ensure there are margins to allow for the 5053 # finite size of the symbols. In v2.x, margins 5054 # are present by default, so we disable this 5055 # scatter-specific override. 5056 if mpl.rcParams['_internal.classic_mode']: File ~/Documents/developer/RDtattoo/.venv/lib/python3.13/site-packages/matplotlib/artist.py:1233, in Artist._internal_update(self, kwargs) 1226 def _internal_update(self, kwargs): 1227 """ 1228 Update artist properties without prenormalizing them, but generating 1229 errors as if calling `set`. 1230 1231 The lack of prenormalization is to maintain backcompatibility. 1232 """ -> 1233 return self._update_props( 1234 kwargs, "{cls.__name__}.set() got an unexpected keyword argument " 1235 "{prop_name!r}") File ~/Documents/developer/RDtattoo/.venv/lib/python3.13/site-packages/matplotlib/artist.py:1206, in Artist._update_props(self, props, errfmt) 1204 func = getattr(self, f"set_{k}", None) 1205 if not callable(func): -> 1206 raise AttributeError( 1207 errfmt.format(cls=type(self), prop_name=k), 1208 name=k) 1209 ret.append(func(v)) 1210 if ret: AttributeError: PathCollection.set() got an unexpected keyword argument 'log'
In [ ]: